<template>
	<view>
		<view style="padding: 10px">客户数：{{ totalCount || 0 }}</view>

		<uni-list>
			<view v-if="fissionCustomer?.length > 0">
				<uni-list-item v-for="(item, index) in fissionCustomer" :key="index"
					:title="(item.ciName || '') + (item.ciAlia ? '(' + item.ciAlia + ')' : '') + (item.ciPhon || '')"
					:rightText="item.ciFrom === '新客' ? '新客' : '老客'" :thumb="item.ciAvat" link="navigateTo"
					:to="'/pages/boss/customer_relationship?ciUuid=' + item.ciUuid" />
			</view>
		</uni-list>
	</view>
</template>

<script>
	import {
		mapGetters
	} from "vuex";
	import {
		getCustomerByFission
	} from "../../utils/api.js"
	export default {
		data() {
			return {
				fissionCustomer: [],
				tempImageUrl: "http://jdc.jd.com/img/100x100/",
				totalCount: 0
			}
		},
		onLoad(params) {
			if (params.osUuid) {
				this.getFissionCustomer(params.osUuid)
			}
		},
		methods: {
			async getFissionCustomer(osUuid) {
				let res = await getCustomerByFission(osUuid);
				if (res) {
					let fissionCustomer = res.nodes?.filter(item => item.relation.totalCount > 0)
					this.fissionCustomer = fissionCustomer
					this.totalCount = fissionCustomer.length
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		height: 100%
	}
</style>
